import dayjs from 'dayjs';
import mongoose, { Schema } from 'mongoose';

export interface ISite {
	_id: string;
	title: string;
	description: string;
	keywords: string;
	globalCss: string;
	globalJs: string;
	about: string;
	isUse: boolean;
	createdAt: string;
	updatedAt: string;
}

const SiteSchema = new Schema<ISite>(
	{
		title: { type: String, required: true },
		description: { type: String, required: true },
		keywords: { type: String, required: true },
		globalCss: { type: String, default: '' },
		globalJs: { type: String, default: '' },
		about: { type: String, default: '' },
		isUse: { type: Boolean, default: false },
		createdAt: {
			type: String,
			default: () => dayjs().format('YYYY年MM月DD日 HH:mm:ss'),
		},
		updatedAt: {
			type: String,
			default: () => dayjs().format('YYYY年MM月DD日 HH:mm:ss'),
		},
	},
	{
		collection: 'site',
	}
);

export const SiteModel = mongoose.model<ISite>('Site', SiteSchema);
